package cn.yunhe.servlet;

import cn.yunhe.bean.HotelPrice;
import cn.yunhe.biz.HotelService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/HotelPriceServlet")
public class HotelPriceServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
               doPost(req, resp);

           }
 	    @Override
 	   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
                           String id = request.getParameter("id");
                           HotelService hotelService = new HotelService();
                           List<HotelPrice> hotelPriceList = hotelService.getHotelpriceByuserid(id);
                           int sum=hotelService.getScenerySum();
                           if (hotelPriceList != null && hotelPriceList.size() > 0) {
                           request.setAttribute("sum",sum);
                           request.setAttribute("hotelPriceList", hotelPriceList);
                           request.getRequestDispatcher("ownHotel.jsp").forward(request, response);
            }
    }
}


